package com.data.documents;

import java.util.Calendar;

import com.users.User;

/**
 * This class holds information about office's appointment.
 * 
 * @author Elizabeth
 * 
 */
public class Appointment extends UserDocument {

	private long dateTime;
	private String reason;
	private User desiredDoctor;

	/**
	 * Creates an Appointment
	 * 
	 * @param docId
	 *            the documents Id
	 * @param dateTime
	 *            the date and time
	 * @param reason
	 *            the reason for the appointment
	 * @param desiredDoctor
	 *            the desired doctor for the appointment
	 */
	public Appointment(String docId, long dateTime, String reason,
			User desiredDoctor) {
		super(docId, "appointments");
		this.dateTime = dateTime;
		this.reason = reason;
		this.desiredDoctor = desiredDoctor;
	}

	/**
	 * creates and appointment with the given id
	 * 
	 * @param docId
	 */
	public Appointment(String docId) {
		this(docId, 0l, "", null);
	}

	/**
	 * get the date and time of the appointment
	 * 
	 * @return a long of the date and time
	 */
	public long getDateTime() {
		return dateTime;
	}

	/**
	 * Set the date and time of the appointment
	 * 
	 * @param dateTime
	 *            date and time
	 */
	public void setDateTime(long dateTime) {
		this.dateTime = dateTime;
	}

	/**
	 * Get the reason for the appointment
	 * 
	 * @return reason for appointment
	 */
	public String getReason() {
		return reason;
	}

	/**
	 * set the reason for the appointment
	 * 
	 * @param reason
	 *            reason for the appointment
	 */
	public void setReason(String reason) {
		this.reason = reason;
	}

	/**
	 * Get the desired doctor for the appointment
	 * 
	 * @return the desired Doctor
	 */
	public User getDesiredDoctor() {
		return desiredDoctor;
	}

	/**
	 * set the desired doctor
	 * 
	 * @param desiredDoctor
	 */
	public void setDesiredDoctor(User desiredDoctor) {
		this.desiredDoctor = desiredDoctor;
	}

	/**
	 * get the data in the appointment
	 * 
	 * @return data
	 */
	public Object[] getData() {
		Object[] o = { dateTime, reason, desiredDoctor };
		return o;
	}

	/**
	 * Returns a string array containing important information to display about
	 * the appointment
	 * 
	 * @return string array
	 */
	public String[] getDataAsStrings() {
		Calendar c = Calendar.getInstance();
		c.setTimeInMillis(dateTime);
		String[] sample = {
				"Appointment",
				(c.get(Calendar.MONTH)+1) + "/" + c.get(Calendar.DAY_OF_MONTH)
						+ "/" + c.get(Calendar.YEAR),
				"With " + desiredDoctor.getName() };
		return sample;
	}
}